<%@ page import="com.mysql.jdbc.Driver" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Connection" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
  <title>JSP - Hello World</title>
</head>
<body>
<%
  Class.forName("com.mysql.cj.jdbc.Driver");
  String url = "jdbc:mysql://localhost:3306/dbnews?serverTimezone=Asia/Shanghai";
  String username = "root";
  String password = "1234";
  Connection conn = DriverManager.getConnection(url, username, password);
  if(conn!=null){
    out.print("数据库连接成功！");
  }
  else {
    out.print("数据库连接失败！");
  }
  if(conn != null) {
    conn.close();
  }

%>
<br/>
<a href="hello-servlet">Hello Servlet</a>
</body>
</html>